//
//  CustomUILable.m
//  UI02_UILable_UITextField_UIImageView_UIButton
//
//  Created by aaaaaa on 16/6/6.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CustomUILable.h"

@implementation CustomUILable

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

//重写父类的初始化方法
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        //self指CustomUILable的对象
        
        //设置显示文本内容
        self.text = @"用户名";
        //设置文本颜色为蓝色
        self.textColor = [UIColor blueColor];
        
        
    }
    return self;
}

//实现自定义初始化时方法
- (instancetype)initWithFrame:(CGRect)frame withText:(NSString *)text{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.text = text;
        
        //调用设置默认属性值的方法
        [self setPropertys];
    }
    return self;
}

#pragma mark - UILable常用的API
- (void)setPropertys{
    self.textColor = [UIColor blueColor];
    
    //设置行数为3 指的是lable里最大的行数
    self.numberOfLines = 3;
    
    //设置文本字体为系统字体，字号为20
    //字体默认值为：系统字体，字号为17
    self.font = [UIFont systemFontOfSize:20.0f ];
    
    //文本靠右对齐 默认靠左对齐
    self.textAlignment = NSTextAlignmentRight;
    
    //文本断行方式
    self.lineBreakMode = NSLineBreakByTruncatingMiddle;
    
    //阴影(shadow)的颜色
    self.shadowColor = [UIColor redColor];
    
    //阴影的偏移量
    //width 代表水平方向的偏移量，正数向右偏移，负数向左偏移
    //height 代表垂直方向的偏移量，正数向下偏移，负数向上偏移
    self.shadowOffset = CGSizeMake(2, 5);

    self.backgroundColor = [UIColor yellowColor];
}






















@end
